package ModelLayer;
import java.util.ArrayList;

public class LendingCollection
{
    public ArrayList<Lending>lendingCollection;
    private static LendingCollection instance = null;
    
    public static LendingCollection getInstance() {
        if (instance == null) {
            instance = new LendingCollection();
        }
        return instance;
    }
    
    
    public LendingCollection()
    {
        lendingCollection = new ArrayList<Lending>();
    }

    
    
    public void addLending(Lending newLending) {
        lendingCollection.add(newLending);
    }
    
    public void deleteLending(Lending delLending) {
        lendingCollection.remove(delLending);
    }
    
    public Lending findLending(int id) {
        int i = 0;
        Lending result = null;
        boolean found = false;
        while (i < lendingCollection.size() && !found) {
            if (lendingCollection.get(i).getLendingId()== id) {
                result = lendingCollection.get(i);
                found = true;
            }
            i++;
        }
        return result;
    }
    
    public ArrayList<Lending>getAll() {
        return lendingCollection;
    }

}
